from selenium.webdriver.common.by import By

from page_object.pages.BasePage import BasePage
from page_object.pages.PasswordPage import PasswordPage


class LoginPage(BasePage):
    _et_phone = (By.ID, "et_phone")
    _erification_code = (By.ID, 'verificationcodeinput')
    _tv_next = (By.ID, 'tv_next')
    _xieyi_rb = (By.ID,'xieyi_rb')
    def loginByOthers(self):
        '''
        验证码登录
        :return:
        '''
        # self.find_by_xpath('切换手机号登录').click()
        self.find_by_xpath('切换手机号登录').click()
        self.find(self._et_phone).send_keys('18538285467')
        self.find_by_xpath('下一步').click()
        self.find_by_xpath('同意').click()
        self.find_by_xpath('下一步').click()
        self.find(self._erification_code).send_keys('9999')
        return self

    def loginByPhone(self, phone):
        '''
        手机号密码登录
        :param phone: 手机号
        :return: 密码登录页面
        '''
        self.find(self._xieyi_rb).click()
        self.find(self._et_phone).send_keys(phone)
        self.find(self._tv_next).click()
        return PasswordPage()